package huizhi.net;

import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
//        InetAddress localHost = InetAddress.getLocalHost();
//        System.out.println(localHost);
        String url = "D:\\　\\后端";
        String value = "4.集合.doc";
        List<String> arr = new ArrayList<>();
        search(url,value,arr);
        for (String s : arr) {
            System.out.println(s);
        }
        //查找



    }
    public static void search(String url,String v,List<String> arr){
        File file = new File(url);
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()){
                if (file1.getName().equals(v)){
                    arr.add(file1.getAbsolutePath());
                }
            }else {
                search(file1.getAbsolutePath(),v,arr);
            }
        }
    }
}
